Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
Module Build Failed: Duplicate Declaration "Editor"

I am trying to implement "RichEditor" example provided by Facebook in my project Here is the code:

import React from 'react;
import { Component } from 'react';
import { Editor, EditorState, RichUtils } from 'draft-js';
import { Map } from 'immutable';

'use strict';

const { Editor, EditorState, RichUtils } = Draft;

//rest of the code...

Whenever I tried to build using webpack-dev-server, I am getting the following error. I checked StackOverflow to see if some other user has encountered an exact error. But, couldn't find one.

Module Build Failed: Duplicate Declaration "Editor"

'use strict';
> const { Editor, EditorState, RichUtils } = Draft;

export class ...{}

Where am I going wrong?

Note: I am new to ReactJS.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You're importing Editor up top, and then you are also defining it again when you are destructuring Draft.

You either need to alias Editor in the import of draft-js like this:

import { Editor as DEditor, EditorState, RichUtils } from 'draft-js';

From here you would use Deditor instead of Editor. Then you would be free to name the const Editor below...

Or, just don't destructure the Draft object below.

Instead of const { Editor, EditorState, RichUtils } = Draft;, access the property of Draft with dot syntax. i.e. Draft.Editor, Draft.EditorState, etc...

over 4 years ago · Santiago Trujillo Relatório

0

Also this duplicate declaration error happens if you are importing a predefined default import with the same name as a component somewhere else in your imports.

Example:

import bla from 'react-bla';
://more imports
://more imports
import bla from '../Components/bla/bla';
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda